/*

Imebra 2011 build 2011-06-29_23-24-13

Imebra: a C++ Dicom library

Copyright (c) 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010 by Paolo Brandoli
All rights reserved.

Redistribution and use in source and binary forms, with or without modification,
 are permitted provided that the following conditions are met:
- Redistributions of source code must retain the above copyright notice, this
  list of conditions and the following disclaimer.
- Redistributions in binary form must reproduce the above copyright notice,
  this list of conditions and the following disclaimer in the documentation
  and/or other materials provided with the distribution.

THIS SOFTWARE IS PROVIDED BY THE FREEBSD PROJECT ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FREEBSD PROJECT OR CONTRIBUTORS BE
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

The views and conclusions contained in the software and documentation are those of the authors
 and should not be interpreted as representing official policies, either expressed or implied,
 of the Imebra Project.

Imebra is available at http://imebra.com



*/

/*! \file colorTransform.h
    \brief Declaration of the base class used by all the color transforms.

*/


#if !defined(imebraColorTransform_E27C63E7_A907_4899_9BD3_8026AD7D110C__INCLUDED_)
#define imebraColorTransform_E27C63E7_A907_4899_9BD3_8026AD7D110C__INCLUDED_

#include "transform.h"


///////////////////////////////////////////////////////////
//
// Everything is in the namespace puntoexe::imebra
//
///////////////////////////////////////////////////////////
namespace puntoexe
{

namespace imebra
{

namespace transforms
{

/// \namespace colorTransforms
/// \brief This namespace contains all the classes
///         involved in the transformation between several
///         color spaces.
///
/// The color transformation is performed on images (see
///  puntoexe::imebra::image).
///
///////////////////////////////////////////////////////////
namespace colorTransforms
{

/// \addtogroup group_transforms
///
/// @{

///////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////
/// \brief This is the base class used by the color
///         transforms classes.
///
/// Each color transform class can handle a color space
///  conversion from one color space to another.
///
/// The class colorTransformsFactory can select the
///  right transform automatically when queried with
///  the initial and the final color spaces as parameters.
///
///////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////
class colorTransform: public transformHandlers
{
public:
	/// \brief Return the name of the color space that this 
	///         colorTransform can convert.
	///
	/// @return a string with the name of the color space that
	///          can be converted by the colorTransform
	///
	///////////////////////////////////////////////////////////
	virtual std::wstring getInitialColorSpace()=0;

	/// \brief Return the name of the color space that this
	///         colorTransform can generate.
	///
	/// @return a string with the name of the color space that
	///          can be generated by the colorTransform
	///
	///////////////////////////////////////////////////////////
	virtual std::wstring getFinalColorSpace()=0;

	/// \brief Create another instance of the colorTransform
	///         class.
	///
	/// The new instance will have the same type of the 
	///  instance on which this function is called.
	///
	/// @return a new instance of the colorTransform. The new
	///          instance will have the same class of the
	///          instance on which the function is called
	///
	///////////////////////////////////////////////////////////
	virtual ptr<colorTransform> createColorTransform()=0;

        virtual ptr<image> allocateOutputImage(ptr<image> pInputImage, imbxUint32 width, imbxUint32 height);

protected:
	// Performs the color transform
	///////////////////////////////////////////////////////////
        void checkColorSpaces(const std::wstring& inputHandlerColorSpace, const std::wstring& outputHandlerColorSpace);

};


class colorTransformException: public transformException
{
public:
	colorTransformException(const std::string& message): transformException(message){}
};

class colorTransformExceptionWrongColorSpace: public colorTransformException
{
public:
	colorTransformExceptionWrongColorSpace(const std::string& message): colorTransformException(message){}
};

class colorTransformExceptionWrongSize: public colorTransformException
{
public:
	colorTransformExceptionWrongSize(const std::string& message): colorTransformException(message){}
};


///////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////
/// \internal
/// \brief This class is used by the colorTransform derived
///         classes to register themself.
///
/// Each colorTransform derived class statically allocate
///  a registerColorTransform class that register the
///  color transforms in the colorTransformsFactory.
///
///////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////
class registerColorTransform
{
public:
	/// \brief Register the specified color transform
	///
	/// @param newColorTransform the color transform to be
	///                           registered
	///
	///////////////////////////////////////////////////////////
	registerColorTransform(ptr<colorTransform> newColorTransform);
};

/// @}

} // namespace colorTransforms

} // namespace transforms

} // namespace imebra

} // namespace puntoexe


#endif // !defined(imebraColorTransform_E27C63E7_A907_4899_9BD3_8026AD7D110C__INCLUDED_)
